/*
 * ZohoDocument.java
 *
 */

package pl.edu.pw.mini.adapter.documents;
import java.io.File;
import java.lang.Long;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
 *
 * @author Maciek
 */
public abstract class ZohoDocument extends Document{
    
    protected Node zohoReference;
    
    protected Map<String,String> valueMap;
    
    protected Document.Type documentType;
    
    protected File documentSource;
    
    
    /** Creates a new instance of ZohoDocument */
    public ZohoDocument(Node zohoNode){    
        zohoReference=zohoNode;
        final NodeList nList=zohoReference.getChildNodes();
        Map<String,String> hmap=new HashMap<String,String>();
        for(int i=0;i<nList.getLength();i++){
            Node n=nList.item(i);
            hmap.put(n.getNodeName(),n.getTextContent());
        }
        valueMap=hmap;
    }
    
    public abstract String getTitle();
    
    public void setFile(File f) {
        documentSource =f;
    }
    
    public abstract Document.Type getType();
    
    public abstract Date getCreationTime();
    
    protected Date getTimeFromMillis(String tmStr){
        if (tmStr==null || "".equals(tmStr)){
            return new Date(0);
        }
        Date dat=new Date(Long.parseLong(tmStr));
        return dat;
    }
    
    public abstract Date getLastModifiedTime();
    
    public abstract String getAuthor();
    
    public abstract String getLastModifiedBy();
    
    public abstract String getId();
}
